var app = getApp();
import testData from "../../utils/testWardrobeData.js"
import { bodyLays } from "../../utils/testPersonData"

Page({
    data: {
        baseUrl: app.globalData.baseUrl,
        isIndexFrontAniEnd: false,
        isBottomFrontAniEnd: false,
        isRightFrontAniEnd: false,
        showBodyLays: bodyLays,

        swiperData: testData,
        currentSwiper: 0
    },
    onLoad: function () {
        console.log('onLoad');

        // 组件实例
        this.rightView = this.selectComponent("#index-right-lay"); //组件的id

        // 右侧菜单弹出动画  
        var tempRightAnimation = jd.createAnimation({
            duration: 200,
            timingFunction: 'cubic-bezier(0,0.14,1,0.18)',
            delay: 100
        });
        tempRightAnimation.opacity(1.0).translate(-50, 0).step()

        let _self = this;
        // 右侧菜单延迟开始
        setTimeout(() => {
            _self.setData({
                rightAnimation: tempRightAnimation.export()
            })
        }, 500);
    },

    /**
   * 右侧菜单动画结束后 中间主要部分alpha动画显示出来
   */
    doMainAlphaAni() {
        var tempAlphaAnimation = jd.createAnimation({
            duration: 500,
            timingFunction: 'cubic-bezier(0,0.14,1,0.18)',
            delay: 0
        });
        tempAlphaAnimation.opacity(1.0).step()

        this.setData({
            mainAnimation: tempAlphaAnimation.export()
        })
    },

    /**
     * 右侧动画结束
     */
    onRightAniEnd() {
        console.log("index --- onRightAniEnd")
        this.setData({
            isRightFrontAniEnd: true,
        })
        this.doMainAlphaAni();
    },

    onSwiperChange(e) {
        let { current } = e.detail
        this.setData({ currentSwiper: current })     
        console.log("onSwiperChange --- ", e)   
    }
});